<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>16-构造函数方法Array.from</title>
</head>
<body>
    <ul>
        <li>百度</li>
        <li>新浪</li>
        <li>阿里</li>
        <li></li>
        <li>抖音</li>
        <li>腾讯</li>
    </ul>
    <script>
        var arr = [1,2,3];
        //console.log(arr);
        //伪数组转换成真正数组
        var lis = document.querySelector('ul').querySelectorAll('li');
        //console.log(lis);
        //var newArr = Array.from(lis);
        //console.log(newArr);
        // var newArr1 = Array.from(lis,function(val){
        //     //给li添加个属性
        //     console.log(val);
        //     val.setAttribute('type',val.innerHTML);
        // });

        Array.from(lis,(val)=>{
            val.setAttribute('type',val.innerHTML);
        });
        var newArr3 = Array.from(lis).filter((val)=>{
            return val.getAttribute('type')!='';
        });
        console.log(newArr3);
    </script>
</body>
</html>